import { _decorator, Component, director, find, instantiate, Node, Prefab } from 'cc';
import { Permanent } from './Permanent';
const { ccclass, property } = _decorator;

@ccclass('Jump')
export class Jump extends Component {
    @property(Prefab)
    zhedang:Prefab = null
    @property(Number)
    l:number = 1
    start() {
        if(find('Permanent').getComponent(Permanent).levelnum<this.l-1){
            let pre = instantiate(this.zhedang)
            this.node.addChild(pre)
            pre.setPosition(0,0,0)
        }
        this.node.on(Node.EventType.TOUCH_START,(e)=>{
            if(find('Permanent').getComponent(Permanent).levelnum>=this.l-1){
                director.loadScene('level'+this.l)
            }else{
                console.log('暂未解锁')
                return
            }
        },this)
    }

    update(deltaTime: number) {
        
    }
}


